import React, { useState } from 'react';
import Dict from './Dict';

type DataType = DICT_TYPE.Info;

const initCurrentRow: DataType = {
  parentId: '0',
  code: '',
  id: '',
  seq: 0,
  title: '',
  value: '',
};
const TableList: React.FC = () => {
  const [currentRow, setCurrentRow] = useState<DataType>(initCurrentRow);
  const [isShow, setIsShow] = useState(true);
  const changeShow = (show: boolean, data = initCurrentRow) => {
    setCurrentRow(data);
    setIsShow(show);
  };
  return isShow ? (
    <Dict key="dict" changeShow={changeShow} currentRow={currentRow} isShow={isShow} />
  ) : (
    <Dict key={currentRow.id} currentRow={currentRow} changeShow={changeShow} isShow={isShow} />
  );
};

export default TableList;
